package com.AndroidApp.codememo;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class CodeMemoAppActivity extends Activity {
    /** Called when the activity is first created. */
	EditText password;
	Intent intent = new Intent(); 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        password = (EditText) findViewById(R.id.pswd);

    }

    public void onClickSubmit(View v) {
        // Perform action on click
    	
    	//if((password.getText().toString()).equalsIgnoreCase(null))
    	//{
    		SharedPreferences myMemos = this.getSharedPreferences("myMemos", MODE_WORLD_READABLE);
            boolean prefName = myMemos.contains("MY_PASSWORD");
            
           	if(prefName)
               {
    	        	SharedPreferences myMemo = this.getSharedPreferences("myMemos", MODE_WORLD_READABLE);
    	            String prefNames = myMemo.getString("MY_PASSWORD", "nothing");
    	            if(prefNames.equalsIgnoreCase(password.getText().toString()))
    	            {
    	            	intent.setClass(this,Memomenu.class);
    	             	startActivity(intent);
    	            }
    	            
    	            else
    	            {
    	            	TextView tv= (TextView) findViewById(R.id.errmsg);
    		            tv.setText("Wrong Password...");
    	            }
 
                }
    	        else
    	        {
    	        	intent.setClass(this,CreatePswd.class);
    	         	startActivity(intent);
    	        }
        /*   }
    	else
    	{
    		
           	TextView tv= (TextView) findViewById(R.id.errmsg);
        	tv.setText("Please Enter Password..");
    	 }*/
    	
    	
      }
    
    public void onClickchgpwd(View v) {
        // Perform action on click
    	
    	intent.setClass(this,ChangePswd.class);
    	startActivity(intent);
    	
    }
    

}